home *** CD-ROM | disk | FTP | other *** search
- /*
- * run this with 'test1' as the first command line argument. It will
- * recurse to three levels if the 'test1, 'test2' and 'test3' files are
- * available for it to read. This program works fine with Lattice C
- * but fails miserably with the orignial developers kit.
- * Works ok in Mark Williams C - CJPurcell - 16Jan'87 - added Bconin/pause.
- */
-
- #include "stdio.h"
- #include <osbind.h>
-
- int main(argc,argv) int argc;
- char **argv;
- {
- FILE *in;
- if (argc > 1)
- {
- if ((in = fopen(argv[1],"r")) == NULL) exit(1);
- echofile(in);
- fclose(in);
- }
- Cconws("This is recursive demonstration. Press any key to return\r\n");
- Bconin(2);
- exit(0);
- }
- int echofile(in) FILE *in;
- {
- FILE *newin;
- char line[BUFSIZ];
- while (fgets(line,BUFSIZ,in))
- {
- printf("%s",line);
- if (! strncmp(line,"read ",5))
- {
- line[strlen(line)-1] = 0;
- if ((newin = fopen(line+5,"r")) == NULL) continue;
- echofile(newin);
- fclose(newin);
- }
- }
- return 0;
- }
-